<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/13 0013
 * Time: 下午 7:34
 */
namespace app\api\controller;


use think\Request;

class UploadFile extends BaseController{
//    protected $beforeActionList = [
//        'checkExclusiveScope' => ['only' => 'upload']
//    ];
    public function upload(){
        $file = Request::instance()->file('file');
        if($file){
            $info = $file->validate(config('upload.UPLOAD_RULE'))->move(config('path.Upload_path'));
            if($info){
                $data = [
                    'Relative_path' => $info->getSaveName(),
                    'Absolute_path' => config('miniprogram.MiaoDaoOpenRequestdomain').'/public/upload/'.$info->getSaveName()
                ];
                return show('1','ok',$data);
            }else{
                throw new ParameterException([
                    'msg' => $file->getError(),
                ]);
            }

        }else{
            throw new ParameterException([
                'msg' => '没有获取到上传图片信息'
            ]);
        }

    }
}